$(function(){
	if($.getUrlParam("isShow")){
		$("#num").attr("disabled","disabled");
		$("#cancel").html("返回");
		$("#save").remove();
	}
	initProcNum();
})

function initProcNum(){
	var data = {
			"PROD_ID":$.getUrlParam("prod_id"),
			"USER_ID":$.getUrlParam("user_id"),
			"PRO_ID":$.getUrlParam("proc_id")
	}
	$.jsonAjax("procedureServlet","getProceNumList",data,null,false,function(rtnData){
		if(!isEmpty(rtnData)&&rtnData.data.status=="success"){
			var list = rtnData.data.content.dataList;
			var dataJson = list[0];
			$("#product").val(processUndefined(dataJson.PROD_NAME));
			$("#product_id").val(processUndefined(dataJson.PROD_ID));
			$("#prod_status").val(processUndefined(dataJson.PROD_STATUS_NAME));
			$("#prod_status_id").val(processUndefined(dataJson.PROD_STATUS_CD));
			$("#user_name").val(processUndefined(dataJson.USER_NAME));
			$("#user_id").val(processUndefined(dataJson.USER_ID));
			$("#proc_name").val(processUndefined(dataJson.PRO_NAME));
			$("#proc_id").val(processUndefined(dataJson.PRO_ID));
			$("#num").val(processUndefined(dataJson.NUM));
		} 
	},null);
}

function save(){
	if($("#num").val()){
		var data = {
				"oper_type":"modify",
				"status_cd":"1001",
				"user_id":$("#user_id").val(),
				"prod_id":$("#product_id").val(),
				"proc_id":$("#proc_id").val(),
				"num":$("#num").val()
		}
		$.jsonAjax("procedureServlet","updateProcedureNum",data,null,false,function(rtnData){
			if(!isEmpty(rtnData)&&rtnData.data.status=="success"){
				art.dialog.message("succeed","修改工序记录成功！",function(){
					art.dialog.open.api.close();
					art.dialog.open.origin.queryListData();
				});
			} else{
				art.dialog.message("error","修改工序记录失败！",null);
			}
		});
	} else{
		art.dialog.message("warning","请输入工序数量",null);
	}
}

function cancel(){
	art.dialog.open.api.close();
}